package org.ali.structuralpattern.proxypattern;

import org.ali.structuralpattern.proxypattern.color.Color;
import org.ali.structuralpattern.proxypattern.color.Red;
import org.ali.structuralpattern.proxypattern.proxy.ColorProxy1;
import org.ali.structuralpattern.proxypattern.proxy.ShapeProxy1;
import org.ali.structuralpattern.proxypattern.proxy.ShapeProxy2;
import org.ali.structuralpattern.proxypattern.proxy.ShapeProxy3;
import org.ali.structuralpattern.proxypattern.shape.Circular;
import org.ali.structuralpattern.proxypattern.shape.Shape;

/**
 * 代理模式
 */
public class Main {
    public static void main(String[] args) {
        Shape circular = new Circular();
        Color red = new Red();

        Shape shapeProxy1 = new ShapeProxy1(circular, "测试类");
        shapeProxy1.draw();

        Color redProxy1 = new ColorProxy1(red, "测试类");
        redProxy1.paint();

        Shape shapeProxy2 = (Shape) new ShapeProxy2(circular, "测试类").getProxyInstance();
        shapeProxy2.draw();

        Color redProxy2 = (Color) new ShapeProxy2(red, "测试类").getProxyInstance();
        redProxy2.paint();

        Shape shapeProxy3 = (Shape) new ShapeProxy3(circular, "测试类").getProxyInstance();
        shapeProxy3.draw();

        Color redProxy3 = (Color) new ShapeProxy3(red, "测试类").getProxyInstance();
        redProxy3.paint();
    }
}
